﻿@{
    Page.Title = "CodeCast";
    Layout = "~/_SiteLayout.cshtml";
}

@section Scripts
{
    <script src="~/Scripts/jquery-1.9.1.min.js"></script>
    <script src="~/Scripts/jquery.signalR-1.0.1.min.js"></script>
    <script src="~/signalr/hubs"></script>
    <script>
        $(function () {
            var codecast = $.connection.codecast;

            codecast.client.refresh = function (message) {
                $('#codecast').html(message);
            };

            codecast.client.notify = function (message) {
                $('#connection-count').html(message)
            };

            $.connection.hub.start().done(function () {
                $("#broadcast").click(function () {
                    codecast.server.send($('#code').val());
                    $("#code").val("");
                });
            });
        });
    </script>
}

<div>
    現在、<span id="connection-count"></span>人が接続しています。
</div>
<div style="display: none;">
    <textarea id="code"></textarea>
    <input type="button" id="broadcast" value="broadcast" />
</div>
<pre><code id="codecast"></code></pre>
